<%@ page import="cn.ruituo.service.GradeService" %>
<%@ page import="cn.ruituo.entity.Grade" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.ruituo.entity.Grade2" %>
<%@ page import="cn.ruituo.service.StudentService" %>
<%@ page import="cn.ruituo.entity.Student" %>
<%@ page import="cn.ruituo.util.StrUtil" %><%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2021/3/23
  Time: 9:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
</head>
<body>
<%
    long stuno=Long.parseLong(request.getParameter("stuno"));
    Student student = StudentService.service.get(stuno);
    if(student==null){
        out.print("<script>alert('查无此人');history.back();</script>");
        return;
    }
%>
<form action="updateStudent.jsp?stuno=<%=stuno%>" method="post">
    <%--<input type="hidden" name="stuno" value="<%=stuno%>"/>--%>
    <fieldset>
        <legend>学生信息</legend>
        <label for="">
            姓名: <input type="text" pattern="[\u4E00-\u9FA5]{2,10}" required autofocus placeholder="请输入姓名" value="<%=student.getSname()%>" name="sname">
        </label>
        <label for="">
            性别:
            <div id="gender">
                <input type="radio" name="sex" value="男" checked="checked" class="gender"  /> <img
                    src="images/man.jpg"/>&nbsp;男&nbsp;&nbsp;&nbsp;
                <input type="radio" name="sex" value="女" class="gender"/> <img src="images/women.jpg"/>&nbsp;女&nbsp;
                <input type="radio" name="sex" value="妖" class="gender"/> <img src="images/women.jpg"/>&nbsp;妖&nbsp;
            </div>
        </label>
        <label for="">手机号码: <input type="tel" pattern="1[3578]\d{9}" placeholder="请输入手机号码" name="telephone" value="<%=student.getTelephone()%>">
        </label>
        <label for="">QQ: <input type="text" placeholder="请输入QQ" name="qq" value="<%=student.getQq()%>">
        </label>
        <label for="">微信: <input type="text" placeholder="请输入微信" name="wechat" value="<%=student.getWechat()%>">
        </label>
        <%--<label for="">--%>
        <%--邮箱地址: <input type="email" placeholder="请输入邮箱地址">--%>
        <%--</label>--%>
        <label for="">
            年级:
            <select name="gradeid" id="gradeid">
                <%

                    List<Grade2> grades =GradeService.service.findALL();
                    for (Grade grade : grades) {
                %>

                <option value="<%=grade.getId()%>"  >
                    <%=grade.getGname()%>
                </option>
                <%
                    }
                %>
            </select>
        </label>
        <label for="">
            入学日期: <input name="enterdate" type="date" value="<%=StrUtil.toStr(student.getEnterdate())%>">
        </label>
        <label for="">起运地: <input type="text" placeholder="请输入起运地" name="fromcity" value="<%=student.getFromcity()%>">
        </label>
        <label for="">
            生日: <input name="birthday" type="date" value="<%=StrUtil.toStr(student.getBirthday())%>">
        </label>
        <label for="">住址: <input type="text" placeholder="请输入住址" name="address" value="<%=student.getAddress()%>">
        </label>
       <%-- <label for="">密码: <input type="password" placeholder="请输入密码" name="pass">
        </label>--%>
        <label for="">居民身份证图片: <input type="text" placeholder="请输入居民身份证图片" name="idcardpic">
        </label>
        <label for="" class="btn">
            <input type="submit" value="保存" style="font-size: 22px">
        </label>
    </fieldset>
</form>
<script>
    $(function () {
       $(":radio[name=sex][value=<%=student.getSex()%>]").prop("checked",true);
       $("#gradeid").val('<%=student.getGradeid()%>');
    });
</script>
</body>
</html>
